function Register() {

	if (!check()) {
		return false;
	}
	if (!password()) {
		return false;
	}
	if (!checkPassword()) {
		return false;
	}
	if(!checkemail()){
		return false;
	}

}

function check() {
	var account1 = dwr.util.getValue("user.account");

	if(account1.length==0){
		
		dwr.util.setValue("demoReply", "用户名不能为空！");
		document.getElementById("demoReply").style.color="red";
		return false;
	}
	var element = document.getElementById("name1");
	dwr.util.setValue("name1",null);
		useLoadingImage("images/register_img/loading_icon.gif");
	var account = dwr.util.getValue("user.account");
	

	if (account.length < 5) {
		
		dwr.util.setValue("demoReply", "您输入的用户名格式不对！");
		document.getElementById("demoReply").style.color="red";
		return false;
	}
	if (account.length >= 5) {
		var strSource = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		var ch;
		var temp;
		ch = account.charAt(0);
		temp = strSource.indexOf(ch);
		if (temp == -1) {
			
			dwr.util.setValue("demoReply", "您输入的用户名格式不对！");
			document.getElementById("demoReply").style.color="red";
			return false;
		}
		
		
		dwr.util.setValue("demoReply", null);
		CheckRegister
				.checkRegister(
						account,
						function(data) {
							if (data == 0) {
								
								dwr.util.setValue("demoReply", "用户名已经存在！");
								document.getElementById("demoReply").style.color="red";
								return false;
							}
							if (data == 1) {
								
								dwr.util.setValue("demoReply", "用户可以使用！"); 
								document.getElementById("demoReply").style.color="green";
								

							}
						})
	}
	return true;

}
function password(){
	var password = dwr.util.getValue("user.password");
	var password1 = dwr.util.getValue("password1");

	if (password.length < 5) {
		
		dwr.util.setValue("demoReply1", "您的密码格式不对！");
		dwr.util.setValue("demoReply1-1", null);
		dwr.util.setValue("demoReply1-2", null);
		dwr.util.setValue("demoReply1-3", null);
		document.getElementById("demoReply1").style.color="red";
		document.getElementById("demoReply1-1-1").style.backgroundColor="";
		document.getElementById("demoReply1-2-1").style.backgroundColor="";
		document.getElementById("demoReply1-3-1").style.backgroundColor="";
		document.getElementById("passwordStyle").style.backgroundColor="";
		return false;
	}
	if (password.length >= 5) {
		
		if (password.length < 7) {
			
			document.getElementById("passwordStyle").style.backgroundColor="#ECEEEC";
			dwr.util.setValue("demoReply1", "您的密码强度为：");
			document.getElementById("demoReply1").style.color="";
			dwr.util.setValue("demoReply1-1", " 弱 ");
			dwr.util.setValue("demoReply1-2", " 中 ");
			dwr.util.setValue("demoReply1-3", " 强 ");
			document.getElementById("demoReply1-1-1").style.backgroundColor="#FC0204";
			document.getElementById("demoReply1-2-1").style.backgroundColor="#ECEEEC";
			document.getElementById("demoReply1-3-1").style.backgroundColor="#ECEEEC";
			
		}
		if (password.length >= 7 && password.length < 10) {
			document.getElementById("passwordStyle").style.backgroundColor="#ECEEEC";
			dwr.util.setValue("demoReply1", "您的密码强度为：");
			dwr.util.setValue("demoReply1-1", " 弱 ");
			dwr.util.setValue("demoReply1-2", " 中 ");
			dwr.util.setValue("demoReply1-3", " 强 ");
			document.getElementById("demoReply1-1-1").style.backgroundColor="#FC9A04";
			document.getElementById("demoReply1-2-1").style.backgroundColor="#FC9A04";
			document.getElementById("demoReply1-3-1").style.backgroundColor="#ECEEEC";
		
		}
		if (password.length >= 10) {
			document.getElementById("passwordStyle").style.backgroundColor="#ECEEEC";
			dwr.util.setValue("demoReply1", "您的密码强度为：");
			dwr.util.setValue("demoReply1-1", " 弱 ");
			dwr.util.setValue("demoReply1-2", " 中 ");
			dwr.util.setValue("demoReply1-3", " 强 ");
			document.getElementById("demoReply1-1-1").style.backgroundColor="#34CE04";
			document.getElementById("demoReply1-2-1").style.backgroundColor="#34CE04";
			document.getElementById("demoReply1-3-1").style.backgroundColor="#34CE04";
			
		}
	}
	return true;
}

function checkPassword() {
	var password = dwr.util.getValue("user.password");
	var password1 = dwr.util.getValue("password1");
	if (password < 1) {
		return false;
	}
	if (password != password1) {
		
		dwr.util.setValue("demoReply2", "请再次确认您的密码！");
		document.getElementById("demoReply2").style.color="red";
		return false;
	}
	else {
		
		dwr.util.setValue("demoReply2", null);
		

	}
	return true;

}
function demoReply_display(){
	dwr.util.setValue("demoReply", null);
	
}
function checkemail(){
		var email = dwr.util.getValue("user.email");
		var patrn=/\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
		dwr.util.setValue("demoReply3", null);
		var objExp= new RegExp(patrn);
		if (!objExp.test(email)){
			dwr.util.setValue("demoReply3", "邮箱格式有误!");
			if(email==""){
					dwr.util.setValue("demoReply3", "邮箱不能为空!");
			}
			document.getElementById("demoReply3").style.color="red";
			 return false;
		}else{
			dwr.util.setValue("demoReply3", null);
			 return true;
		}
	}